

function selectJituan() {
    var userId = $("#jituanId").val();
    $.ajax({
        type: "POST",
        url: ctx +"sys/user/selectUserByUserType",
        data: {
            userId:userId,
            userType:3,
        },
        dataType:'json',
        cache: false,
        success: function(data){
            var data = JSON.stringify(data);
            var dataJson = JSON.parse(data);
            if(dataJson.code == "00"){
                var users = dataJson.users;
                var users_count = dataJson.users_count;
                $("#pianquUserId").html("");
                $("#pianquUserId").append("<option value=\"\" selected=\"selected\">所属片区管理员</option>");
                if(users_count > 0){
                    for(var index in users) {
                        var user_id = users[index].userId;
                        var name = users[index].name;
                        var str = "<option value=\""+user_id+"\" >"+name+"</option>";
                        $("#pianquUserId").append(str);
                    }
                }else{
                    var str = "<option value=\"\" selected=\"selected\">----无----</option>";
                    $("#pianquUserId").append(str);
                }
                var shops = dataJson.shops;
                var shops_count = dataJson.shops_count;
                $("#shopId").html("");
                $("#shopId").append("<option value=\"\" selected=\"selected\">所属企业</option>");
                if(shops_count > 0){
                    for(var index in shops) {
                        var shop_id = shops[index].id;
                        var shopName = shops[index].shopName;
                        var str = "<option value=\""+shop_id+"\" >"+shopName+"</option>";
                        $("#shopId").append(str);
                    }
                }else{
                    var str = "<option value=\"\" selected=\"selected\">----无----</option>";
                    $("#shopId").append(str);
                }


            }
        }
    });
}

function selectPianqu(pianquId,form) {
    $.ajax({
        type: "POST",
        url: ctx +"sys/user/selectUserByPianquId",
        data: {
            pianquId:pianquId,
            userType:3,
        },
        dataType:'json',
        cache: false,
        success: function(data){
            var data = JSON.stringify(data);
            var dataJson = JSON.parse(data);
            if(dataJson.code == "00"){
                var users = dataJson.users;
                var users_count = dataJson.users_count;
                $("#pianquUserId").html("");
                $("#pianquUserId").append("<option value=\"\" selected=\"selected\">所属片区管理员</option>");
                if(users_count > 0){
                    for(var index in users) {
                        var user_id = users[index].userId;
                        var name = users[index].name;
                        var str = "<option value=\""+user_id+"\" >"+name+"</option>";
                        $("#pianquUserId").append(str);
                    }
                }else{
                    var str = "<option value=\"\" selected=\"selected\">----无----</option>";
                    $("#pianquUserId").append(str);
                }
                form.render("select");
            }
        }
    });
}

function selectPianquUser(userId,form) {
    $.ajax({
        type: "POST",
        url: ctx +"sys/user/selectUserByUserType",
        data: {
            userId:userId,
            userType:4,
        },
        dataType:'json',
        cache: false,
        success: function(data){
            var data = JSON.stringify(data);
            var dataJson = JSON.parse(data);
            if(dataJson.code == "00"){
                var shops = dataJson.shops;
                var shops_count = dataJson.shops_count;
                $("#shopId").html("");
                $("#shopId").append("<option value=\"\" selected=\"selected\">所属企业</option>");
                if(shops_count > 0){
                    for(var index in shops) {
                        var shop_id = shops[index].id;
                        var shopName = shops[index].shopName;
                        var str = "<option value=\""+shop_id+"\" >"+shopName+"</option>";
                        $("#shopId").append(str);
                    }
                }else{
                    var str = "<option value=\"\" selected=\"selected\">----无----</option>";
                    $("#shopId").append(str);
                }
                form.render("select");
            }
        }
    });
}
